package com.zzx.model;

public class Teacher implements Cloneable{
	
	private int age;
	
	private String name;
	
	private Student student;

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
	public Student getStudent() {
		return student;
	}

	public void setStudent(Student student) {
		this.student = student;
	}

	@Override
	public Teacher clone() throws CloneNotSupportedException
	{
		//该语句实现了对象的浅克隆，只把被克隆的对象值赋值给新的对象。
		Teacher object = (Teacher)super.clone();
		//该语句实现了对象的深克隆
		object.setStudent((Student)object.getStudent().clone());
		
		return object;
	}
	
	@Override
	public String toString() {
		return "teacher[ name="+name +" ,age "+age + ", "+ student + " ]";
	}
	
}
